package com.zara.store.server;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import com.zara.store.common.PalcItemVO;

@Entity
public class PalcItem {
	private int id;
	private Product product;
	private Palc palc;
	private BigDecimal amountRequested;
	private BigDecimal amountReceived = BigDecimal.ZERO;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getId(){
		return id;
	}

	public void setId(int newVal){
		id = newVal;
	}

	@ManyToOne
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public void setAmountRequested(BigDecimal amount) {
		this.amountRequested = amount;
		
	}

	@Column
	public BigDecimal getAmountRequested() {
		return amountRequested;
	}

	@ManyToOne
	public Palc getPalc() {
		return palc;
	}

	public void setPalc(Palc palc) {
		this.palc = palc;
	}

	@Column
	public BigDecimal getAmountReceived() {
		return amountReceived;
	}

	public void setAmountReceived(BigDecimal amountReceived) {
		this.amountReceived = amountReceived;
	}

	@Transient
	public PalcItemVO toVO() {
		return new PalcItemVO(product.getBarcode(), amountRequested);
	}
}
